package es.ucm.fdi.xtremeaudio.modelo.utils;

import java.io.File;
import java.io.FilenameFilter;

/**
 * The class file filter
 * 
 * @author elena
 *
 */
public class FileFilter implements FilenameFilter{

	/**
	 * The directory
	 */
	private File _DIR;
	/**
	 * The extension of accepted files
	 */
	private String _EXTENSION;
	
	/**
	 * Constructor
	 * @param dir the directory
	 * @param ext the extension of accepted files
	 */
	public FileFilter(File dir, String ext){
		set_DIR(dir);
		_EXTENSION = ext;
	}
	
	/*
	 * (non-Javadoc)
	 * @see java.io.FilenameFilter#accept(java.io.File, java.lang.String)
	 */
	public boolean accept(File dir, String name) {
		if(name.contains("." + _EXTENSION))
			return true;
		else return false;
	}

	/**
	 * Set the directory
	 * 
	 * @param _DIR The new directory
	 */
	public void set_DIR(File _DIR) {
		this._DIR = _DIR;
	}

	/**
	 * Get the directory
	 * 
	 * @return _DIR
	 */
	public File get_DIR() {
		return _DIR;
	}

}
